import ajax from './ajax'

const BASE = "http://localhost:9000"
const BASE2 = "http://localhost:5200"
// 普通用户登录

export const reqLogin = (account, password) => ajax(BASE + "/login/user", {
    account,
    password
}, "POST")

//发送验证码请求 
export const reqVercode = (mail, subject) => ajax(BASE + "/vercode", {
    mail,
    subject
}, "POST")

// 注册请求

export const reqRegister = (id, username, password, mail, verCode) => ajax(BASE + "/register/user", {
    id,
    username,
    password,
    mail,
    verCode
}, "POST")

//获取每一页单页列表信息
export const reqProblemList = (page, pageSize, level, categoryId) => ajax(BASE + "/problem/list", {
    page,
    pageSize,
    level,
    categoryId
})

// 提交代码
export const reqSubmitCode = (authorId, problemId, codeLang, codeBody) => ajax(BASE + "/problem/submit", {
    authorId,
    problemId,
    codeLang,
    codeBody,
    "runTime": 1000,
    "runMemory": 256,
    "caseNumber": 1
}, "POST")

// 根据题目id查找题目
export const reqOneProblem = (id) => ajax(BASE + "/problem", {
    id
})

//获取所有的标签
export const reqCategoryList = () => ajax(BASE + "/problem/category")


// 获取所有的提交记录列表
export const reqSubmitsList = (page, pageSize, problemId, username, verdict, codeLang) => ajax(BASE + "/problem/submits", {
    page,
    pageSize,
    problemId,
    username,
    verdict,
    codeLang
})

// 获取单次提交详情
export const reqSubmitOne = (id) => ajax("/problem/submit", {
    id
})

// 写题目评论
export const reqWriteCommit = (content, problemId, authorVo, parentId=null, toUser=null, level=null) => ajax(BASE + "/problem/comment", {
    content,
    problemId,
    authorVo,
    parentId,
    toUser,
    level
}, "POST")

// 获取题目评论列表
export const reqCommitLists = (page, pageSize, problemId) => ajax(BASE + "/problem/comments", {
    page,
    pageSize,
    problemId
})

// 评论点赞
export const reqCommitSupport = (id) => ajax(BASE + "/problem/support/comment", {
    id
}, "POST")

// 获取题目题解
export const reqProblems = (page, pageSize, categoryId, tagId, problemId, username, year, month) => ajax(BASE + "/article/articles", {
    "page": 1,
    "pageSize": 2,
    "categoryId": 1, //分类id	备注的只是示例
    "tagId": 1, // 标签id
    "problemId": 1, // 题目id
    "username": "冰箱的主人", //	作者id
    "year": "2021", // 发布年
    "month": "1" // 发布月
})

// 获取每日题量
export const reqEveryProblems = (id) => ajax(BASE + "/problem/everyday",{id})